n = int(input())
val_list = [int(value) for value in input().split(" ")]
coin_list = [int(value) for value in input().split(" ")]

result = 0
for i,val in enumerate(val_list[1:n+1]):
    if val>val_list[0]:
        result+=coin_list[i+1]
        
print(result)